
import  os 
'''
解析调度sh脚本
'''
sets=set()
file_path='C:\\Users\\me\\Downloads\\营销日报迁移\\营销日报迁移\\调度任务\\'
#files='''dc_wf_proj_dws_sign_rc.sh,dc_wf_proj_dws_sign_ldlf.sh,dc_wf_proj_dws_sign_hqrh.sh,dc_wf_proj_dws_plan.sh'''
files='''dc_wf_market_dataser_cust.sh,dc_wf_market_dataser_hopemet.sh,dc_wf_market_dataser_ldx.sh,dc_wf_market_dataser_proview.sh,dc_wf_market_dataser_warning.sh,dc_wf_market_dataser_zhihui.sh,dc_wf_market_dataser_yxrb.sh,dc_wf_market_dataser_mysql.sh,dc_wf_market_ads.sh,dc_wf_proj_index.sh,qmys_ads_temp.sh,dc_wf_proj_decision.sh,dc_wf_proj_decision_cun.sh,dc_wf_proj_decision_gxch.sh,dc_wf_proj_decision_fx.shdc_wf_proj_ads_decision_sk.sh,dc_wf_proj_ads_decision_yx.sh'''

for file in files.split(','):
    filePath=''.join([file_path,file])
    if os.path.exists(filePath) and os.path.isfile(filePath):
        #print(filePath)
        with open(file=filePath,mode='r+',encoding='utf-8') as f:
            line=f.readline()
            while line:
                if str(line).find('.sql')>=0:
                    for item in line.strip().split(r'/'):
                        if item.find('.sql')>=0:
                            print(item.split('.sql')[0])
                            sets.add(item.split('.sql')[0])
                line=f.readline()
            pass

write_file='out.sql'
with open(file=write_file,mode='w+') as wf:
    for item in sets:
        wf.write(item)
        wf.write('\n')

